
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript" src="js/BigData/loadjs.js?v=1"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="https://api.map.baidu.com/api?v=3.0&ak=l4zKPgF3ihF8lciY2QGmpsvW"></script>
		<script type="text/javascript" src="https://api.map.baidu.com/library/DistanceTool/1.2/src/DistanceTool_min.js"></script>
		<style type="text/css">
			body {
				width: 100%;
				height: 100%;
				margin: 0px;
				padding: 0px;
			}
			.close {
			    background: orange;
			    color: red;
			    border-radius: 12px;
			    line-height: 20px;
			    text-align: center;
			    height: 20px;
			    width: 20px;
			    font-size: 18px;
			    padding: 1px;
			}
			/* use cross as close button */
			.close::before {
			    content: "\2716";
			}
			
			.mapTip {
			    display: inline-block;
			    width: auto;
			    -webkit-column-width: 310px;
			}
			.b {
			    FONT-WEIGHT: bold;
			}
			
			.menuHistoryPlay{
				width: 28px;
				height: 28px;
				background-image: url("images/gpsicon/historyline24.png");
				background-repeat:no-repeat;
				background-size:24px 24px;
				display:block;
				cursor: hand;
			}
		</style>
		<script type="text/javascript">
			var bDocumentComplete = false;
			document.onreadystatechange = function()			
			{ 	
			　　 if(document.readyState == "complete")
			　　 { 
					bDocumentComplete = true;
			   　}
			}
			var map;
			var mapBaidu;
			var timeVersion = (new Date()).getTime();
			loadScript([{
				"path": "js/index.js?t=" + timeVersion,
				"type": "js"
			}], LoadMainJs);
			
			function LoadMainJs(){
				LoadMain();
			}
			
			function jsCallback(){
				loadScript([{
					"path": "js/BaiduMap/BaiduLatLngCorrect.js?t=" + iVersion,
					"type": "js"
				},{
					"path": "js/BaiduMap/mapv.js?t=" + iVersion,
					"type": "js"
				}], function(){
					var loadFun = function(){
						globalSettings = parent.globalSettings;
						if (globalSettings["lang"] == "Zh") {
							arrLang = arrLanZHCN;
						} else {
							arrLang = arrLanEn;
						}
						SetCancelAlarm();
						ChangeLan("body", arrLang);
						mapBaidu = new BMap.Map("map", {
							minZoom: 3,
							maxZoom: 19,
							enableMapClick: false
						});
						map = mapBaidu;
						var dLatCenter = 36.910400;
						var dLngCenter = 102.362240;
						if(dMapCenterX != 0 && dMapCenterY != 0){
							var googleXY = CheckXYGpsToBaidu(dMapCenterX, dMapCenterY);
							dLngCenter = googleXY[0].lng;
							dLatCenter = googleXY[0].lat;
						}
						var point = new BMap.Point(dLngCenter, dLatCenter); // 创建点坐标
						mapBaidu.centerAndZoom(point, 5); // 初始化地图,设置中心点坐标和地图级别。
						mapBaidu.enableScrollWheelZoom(); //启用滚轮放大缩小
						mapBaidu.addControl(new BMap.NavigationControl()); //启用导航控件
						mapBaidu.addControl(new BMap.MapTypeControl({
							mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP]
						}));
						mapBaidu.addEventListener("moving", function(e) {
							var pointCenter = mapBaidu.getCenter();
							dMapZoom = mapBaidu.getZoom();
							var baiduXY = CheckXYBaiduToGps(pointCenter.lng, pointCenter.lat);
							dMapCenterX = baiduXY[0].lng;
							dMapCenterY = baiduXY[0].lat;
						});
						AddMapv(1);
						sGlobalToken = parent.sGlobalToken;
						parent.AddGpsToMap();
						
						function AddMapv(mapType) {
							if (imageOnline == undefined) {
								imageOnline = new Image();
								imageOnline.src = 'images/gpsicon/carBlue0.gif';
								imageOnline.onload = function() {};
							}
							if (true) {
								var data = [];
								var map;
								var arrIcon;
								if (mapType == 1) {
									arrBaiduOnlineIconDs = new mapv.DataSet(data);
									arrIcon = arrBaiduOnlineIconDs;
									map = mapBaidu;
								} 
								/* else {
									map = mapGoogle;
								} */
								var options = {
									draw: 'icon',
									size: 12,
									font: '18px Arial',
									offsetText: { // 文本便宜值
										x: 16,
										y: 36
									},
									methods: { // 一些事件回调函数
										click: function(item) { // 点击事件，返回对应点击元素的对象值
											TerminalIconClick(item);
										},
										tap: function(item) {
											TerminalIconClick(item); // 只针对移动端,点击事件
										}
									}
								}
								if (mapType == 1) {
									var mapvLayer = new mapv.baiduMapLayer(map, arrIcon, options);
								}
							}
							if (imageOffline == undefined) {
								imageOffline = new Image();
								imageOffline.src = 'images/gpsicon/carGray0.gif';
								imageOffline.onload = function() {};
							}
							if (true) {
								var data = [];
								var map;
								var arrIcon;
								if (mapType == 1) {
									arrBaiduOfflineIconDs = new mapv.DataSet(data);
									arrIcon = arrBaiduOfflineIconDs;
									map = mapBaidu;
								} 
								/* else {
									map = mapGoogle;
								} */
								var options = {
									draw: 'icon',
									size: 12,
									font: '18px Arial',
									offsetText: { // 文本便宜值
										x: 16,
										y: 36
									},
									methods: { // 一些事件回调函数
										click: function(item) { // 点击事件，返回对应点击元素的对象值
											TerminalIconClick(item);
										},
										tap: function(item) {
											TerminalIconClick(item);
										}
									}
								}
								if (mapType == 1) {
									var mapvLayer = new mapv.baiduMapLayer(map, arrIcon, options);
								}
						
							}
							if (imageAlarm == undefined) {
								imageAlarm = new Image();
								imageAlarm.src = 'images/gpsicon/carRed0.gif';
								imageAlarm.onload = function() {}
							}
							if (true) {
								var data = [];
								var map;
								var arrIcon;
								if (mapType == 1) {
									arrBaiduAlarmIconDs = new mapv.DataSet(data);
									arrIcon = arrBaiduAlarmIconDs;
									map = mapBaidu;
								} 
								/* else {
									map = mapGoogle;
								} */
								var options = {
									draw: 'icon',
									size: 12,
									font: '18px Arial',
									offsetText: { // 文本便宜值
										x: 16,
										y: 36
									},
									methods: { // 一些事件回调函数
										click: function(item) { // 点击事件，返回对应点击元素的对象值
											TerminalIconClick(item);
										},
										tap: function(item) {
											TerminalIconClick(item);
										}
									}
								}
								if (mapType == 1) {
									var mapvLayer = new mapv.baiduMapLayer(map, arrIcon, options);
								} 
							}
						}
					}
					if(bDocumentComplete){
						loadFun();
					}
					else{
						$(document).ready(function() {  
							loadFun();
						});
					}
				});
			}
			
			function SetMapCenter(lng, lat, zoom) {
				if(isNaN(lng) || isNaN(lat) || lng == undefined || lat == undefined){
					return;
				}
				setTimeout(function() {
					if (true) {
						var baiduXY = CheckXYGpsToBaidu(lng, lat);
						lng = baiduXY[0].lng;
						lat = baiduXY[0].lat;
						var latlng = new BMap.Point(lng, lat);
						if(mapBaidu == undefined){
							return;
						}
						if (mapBaidu.getZoom() < 15 && zoom == undefined) {
							mapBaidu.centerAndZoom(latlng, 15); //初始化时，即可设置中心点和地图缩放级别。
						} else {
							if (zoom != undefined) {
								mapBaidu.setZoom(zoom);
							}
							mapBaidu.setCenter(latlng);
						}
					} else {
						var googleXY = CheckXYGpsToGoogle(lng, lat);
						lng = googleXY[0].lng;
						lat = googleXY[0].lat;
						if(mapGoogle == undefined){
							return;
						}
						var view = mapGoogle.getView();
						if (view.getZoom() < 15 && zoom == undefined) {
							view.setZoom(15); //初始化时，即可设置中心点和地图缩放级别。
						} else {
							if (zoom != undefined) {
								view.setZoom(zoom);
							}
						}
						view.setCenter([lng, lat]);
			
					}
			
				}, 300);
			}
			
			
			function AddifGpsToMap(data){
				var iLen = 0;
				var arrOnlinePoint = [];
				var arrOfflinePoint = [];
				var arrAlarmPoint = [];
				for (var sKeyT in data) {
					iLen++;
					var value = data[sKeyT];
					if (!value["online"]) {
						if (value["lat"] && value["lng"]) {
							var baiduXY;
							baiduXY = CheckXYGpsToBaidu(value["lng"], value["lat"]);
							/* if (globalSettings["map"] == "Baidu") {
								baiduXY = CheckXYGpsToBaidu(value["lng"], value["lat"]);
							} else {
								baiduXY = CheckXYGpsToGoogle(value["lng"], value["lat"]);
							} */
							var lng = baiduXY[0].lng;
							var lat = baiduXY[0].lat;
							arrOfflinePoint.push({
								geometry: {
									type: 'Point',
									coordinates: [lng, lat]
								},
								deg: value["Angle"],
								icon: imageOffline,
								text: value["name"],
								item: value
							});
						}
					} else if (value["alarmv"]) {
						if (value["lat"] && value["lng"]) {
							var baiduXY;
							baiduXY = CheckXYGpsToBaidu(value["lng"], value["lat"]);
							/* if (globalSettings["map"] == "Baidu") {
								baiduXY = CheckXYGpsToBaidu(value["lng"], value["lat"]);
							} else {
								baiduXY = CheckXYGpsToGoogle(value["lng"], value["lat"]);
							} */
							var lng = baiduXY[0].lng;
							var lat = baiduXY[0].lat;
							arrAlarmPoint.push({
								geometry: {
									type: 'Point',
									coordinates: [lng, lat]
								},
								deg: value["Angle"],
								icon: imageAlarm,
								text: value["name"],
								item: value
							});
						}
					} else {
						if (value["lat"] && value["lng"]) {
							var baiduXY;
							baiduXY = CheckXYGpsToBaidu(value["lng"], value["lat"]);
							/* if (globalSettings["map"] == "Baidu") {
								baiduXY = CheckXYGpsToBaidu(value["lng"], value["lat"]);
							} else {
								baiduXY = CheckXYGpsToGoogle(value["lng"], value["lat"]);
							} */
							var lng = baiduXY[0].lng;
							var lat = baiduXY[0].lat;
							arrOnlinePoint.push({
								geometry: {
									type: 'Point',
									coordinates: [lng, lat]
								},
								deg: value["Angle"],
								icon: imageOnline,
								text: value["name"],
								item: value
							});
						}
					}
				}
				arrBaiduOfflineIconDs.set(arrOfflinePoint);
				arrBaiduOnlineIconDs.set(arrOnlinePoint);
				arrBaiduAlarmIconDs.set(arrAlarmPoint);
				if(infoWindowVehID != undefined && infoWindowVehID.length > 0 && data[infoWindowVehID] != undefined){
					var value = data[infoWindowVehID];
					if (value["lat"] && value["lng"]) {
						var baiduXY;
						baiduXY = CheckXYGpsToBaidu(value["lng"], value["lat"]);
						/* if (globalSettings["map"] == "Baidu") {
							baiduXY = CheckXYGpsToBaidu(value["lng"], value["lat"]);
						} else {
							baiduXY = CheckXYGpsToGoogle(value["lng"], value["lat"]);
						} */
						var lng = baiduXY[0].lng;
						var lat = baiduXY[0].lat;
						var rowT = {
							geometry: {
								type: 'Point',
								coordinates: [lng, lat]
							},
							deg: value["Angle"],
							text: value["name"],
							item: value
						};
						TerminalIconClick(rowT, true);
					}
				}
			}
		
			var infoWindowVeh;
			var infoWindowVehID;
			function TerminalIconClick(item, bUpdate) {
				if (item == null || item == undefined) {
					return;
				}
				globalIconClickID = item.item["id"];
				if(item.item["time"] == undefined){
					item.item["time"] = "";
				}
				if(item.item["positionstatus"] == undefined){
					item.item["positionstatus"] = "";
				}
				if(item.item["unitstatus"] == undefined){
					item.item["unitstatus"] = "";
				}
				if(item.item["speedangle"] == undefined){
					item.item["speedangle"] = "";
				}
				/* var sHtml = "<label datalang='Plate'>" + arrLang["Plate"] + "</label>：" + item.item["name"];
				sHtml += "&nbsp;&nbsp;&nbsp;&nbsp;<label datalang='Time'>" + arrLang["Time"] + "</label>：" + item.item["time"];
				sHtml += "<br /><label datalang='State'>" + arrLang["State"] + "</label>：" + item.item["positionstatus"] + item.item[
					"unitstatus"];
				sHtml += "<br /><label datalang='SpeedAngle'>" + arrLang["SpeedAngle"] + "</label>：" + item.item["speedangle"];
				if (item.item["mileage"] != undefined) {
					sHtml += "&nbsp;&nbsp;&nbsp;<label datalang='Mileage'>" + arrLang["Mileage"] + "</label>：" + (item.item["mileage"] /
						1000.0).toFixed("0.0") + "<label datalang='Km'>" + arrLang["Km"] + "</label>";;
				}
				sHtml += "&nbsp;&nbsp;&nbsp;<label datalang='Oil'>" + arrLang["Oil"] + "</label>：" + (item.item["Oil"] == undefined ?
					"" : item.item["Oil"]);
				sHtml += "<br /><label datalang='Address'>" + arrLang["Address"] + "</label>：<label id='lblLocation'></label>";
				 */
				var sHtml = '<div class="mapTip"><span class="b">' + arrLang["Time"] + '：</span>&nbsp;' + item.item["time"] + '&nbsp;&nbsp;&nbsp;&nbsp;<br />'
					+ '<span class="b">' + arrLang["SpeedAngle"] + '：</span>&nbsp;' + item.item["speedangle"] + '<br />'
					+ '<span class="b">' + arrLang["Address"] + '：</span><span id="lblLocation"></span><br />'
					+ '<span class="b">'+ arrLang["Mileage"] + '：</span>&nbsp;' + (item.item["mileage"] / 1000.0).toFixed("0.0") + arrLang["Km"] + '</label>&nbsp;&nbsp;&nbsp;&nbsp;'
					+ '<span class="b">'+ arrLang["Oil"] + '：</span>&nbsp;' + (item.item["Oil"] == undefined ?	"" : item.item["Oil"]) + '</label><br />'
					+ '<span class="b">' + arrLang["State"] + '：</span>&nbsp;' + item.item["positionstatus"] + item.item["unitstatus"] + '<br />'
					+ '<span class="menuHistoryPlay" title="' + arrLang["HistoryPlay"] + '" onclick="" onmouseout="">&nbsp;&nbsp;</span></div>';
				
				//$('#mapTipsDetail').html(sHtml);
				/* $('#divIconClickCancel')[0].addEventListener('click', function(e) {
					globalIconClickID = "";
					$('#mapTips').hide();
				}); */
				infoWindowVehID = item.item["id"];
				var pointinfoWindow = new BMap.Point(item.geometry.coordinates[0], item.geometry.coordinates[1]);
				if(bUpdate){
					infoWindowVeh.setContent(sHtml);
					infoWindowVeh.setTitle(item.item["name"]);
				}
				else{
					openInfoWindowTip(item.item["name"],sHtml, pointinfoWindow);
				}
				/* if(infoWindowVeh == undefined){
					infoWindowVeh = new BMap.InfoWindow(sHtml); 
					map.openInfoWindow(infoWindowVeh, pointinfoWindow);
				}
				else{
					infoWindowVeh.setContent(sHtml);
					infoWindowVeh.redraw();
					map.openInfoWindow(infoWindowVeh,pointinfoWindow);
				} */
				addressIconClickTick = (new Date()).getTime();
				if (item.item["lng"] != undefined && item.item["lng"] != 0 && item.item["lat"] != 0 && item.item["lat"] !=
					undefined) {
					var iSnt = addressIconClickTick;
					var sLanT = globalSettings["map"];
					if (globalSettings["lang"] != "Zh") {
						sLanT = "Google";
					}
			
					parent.GetLatLngAddress(sLanT, item.item["lng"], item.item["lat"], iSnt, function(add, sn) {
						if (addressIconClickTick == sn) {
							$('#lblLocation').text(add);
							infoWindowVeh.redraw();
						}
					});
				}
			
				//$('#mapTips').show();
			
			}
			
			function openInfoWindowTip(name, content,point){
				var opts = {
								width : 300,     // 信息窗口宽度
								//height: 160,     // 信息窗口高度
								title : name , // 信息窗口标题
								enableMessage:false,//设置允许信息窗发送短息
								enableAutoPan: false
							};
				infoWindowVeh = new BMap.InfoWindow(content,opts);  // 创建信息窗口对象 
				map.openInfoWindow(infoWindowVeh,point); //开启信息窗口
			}
			
			function openW(){
				openInfoWindowTip("ss", new BMap.Point(38.865833333333335,9.007483333333333));
			}
		</script>
	</head>
	<body>
		<div id="map" onclick="this.focus();" style="width: 100%;height: 100%;overflow: hidden;margin:0;"></div>
		<div id="mapTips" style="width:100%;height: 140px; padding: 10px; display: none; z-index: 55; border-bottom: 2px solid #00CC00;background-color:#FFFFFF; font-size:14px; position:fixed; top:0;_position:relative; z-index:100; _top:expression(offsetParent.scrollTop+0);">
			<div id="mapTipsDetail"></div>
			<div id='divIconClickCancel' style='float:right; top:0; position:absolute; right:0; padding:25px;'><span class='close'></span></div>
		</div>
	</body>
</html>
